<!--
 * @author guojiteng
 -->
<template>
  <div id="signList">
    <div class="signList-search">
      <el-collapse-transition>
        <div class="course-search merge">
          <span class="svg-container">
            <svg-icon icon-class="search" />
          </span>
          <el-input v-model.trim="listQuery.signName" placeholder="请输入签到名称搜索" class="search-input" />
          <div class="course-search-btn">
            <el-button class="filter-item" type="primary" @click="handleFilter">搜索</el-button>
            <el-button class="filter-item" type="primary" @click="resettingBtn">重置</el-button>
          </div>
        </div>
      </el-collapse-transition>
    </div>
    <div class="btn-container">
      <div class="btn-container-title">
        <span>签到详情</span>
      </div>
      <div class="btn-container-btns">
        <el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="back">返回</el-button>
      </div>
    </div>
    <div class="table">
      <my-table
        :list="list"
        tag="groupSignList"
        operationwidth="80"
        :list-loading="listLoading"
      >
        <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button type="text" size="mini" @click="handleRecord(scope.row)">签到记录</el-button>
          </template>
        </el-table-column>
      </my-table>
    </div>
    <div class="btn-pagion fix">
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>

  </div>
</template>
<script>
import { queryPage } from '@/views/staffserve/ghhn/api/sign'
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination
import permission from '@/directive/permission/index.js' // 权限判断指令
import elDragDialog from '@/directive/el-drag-dialog' // base on element-ui
import MyTable from '@/components/Table'
import { mapGetters } from 'vuex'
export default {
  name: 'GroupActivitySignList',
  components: { Pagination, MyTable },
  directives: { permission, elDragDialog },
  data() {
    return {
      listQuery: {
        page: 1,
        limit: 10,
        signName: ''
      },
      list: [
      ],
      total: 0,
      listLoading: false
    }
  },
  computed: {
    ...mapGetters([
      'backUrl'
    ])
  },
  created() {
    if (this.$route.query.i) {
      this.getList()
    } else {
      this.back()
    }
  },
  methods: {
    back() {
      if (this.backUrl !== null) { // 如果是小组管理跳入的
        this.$router.push(this.backUrl)
      } else {
        this.$router.push({ path: this.$filterPath('activityManage'), query: { t: this.$route.query.t }})
      }
    },
    /**
     * 查询列表
     */
    getList(obj) {
      const _this = this
      var query = {
        page: obj ? obj.page : this.listQuery.page,
        pageSize: obj ? obj.limit : this.listQuery.limit,
        matchmakerInfoId: this.$route.query.i,
        signName: this.listQuery.signName
      }
      this.listLoading = true
      return new Promise((resolve, reject) => {
        queryPage(query).then(response => {
          this.list = response.data.data.rows
          this.total = response.data.data.total
          _this.listLoading = false
        }).catch(error => {
          reject(error)
          _this.listLoading = false
        })
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    resettingBtn() {
      this.listQuery.signName = ''
      this.listQuery.page = 1
      this.getList()
    },
    handleRecord(row) {
      this.$router.push({ path: this.$filterPath('signRecord'), query: { hi: this.$route.query.i, qi: row.id, gi: this.$route.query.gi }})
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" type="text/scss">
$dark_gray: #bfced6;
@import '@/styles/mixin.scss';
#signList {
  padding: 10px;
  .signList-search {
    background-color: #fff;
    .svg-container {
      padding: 0 5px 0 10px;
      color: $dark_gray;
      vertical-align: middle;
      display: inline-block;
      &_login {
        font-size: 20px;
      }
    }
    .search-input {
      width: 78%;
      input {
        outline: none;
        background: transparent;
        border: none;
        outline: medium;
        padding: 0;
        &:focus {
          outline: none;
          background-color: transparent;
        }
      }
    }
    .el-button.is-round {
      float: right;
      padding: 10px 30px;
    }
  }
  .course-search {
    background-color: #fff;
    padding: 0 10px;
    .svg-container {
      padding: 0 5px 0 10px;
      color: $dark_gray;
      vertical-align: middle;
      display: inline-block;
      &_login {
        font-size: 20px;
      }
    }
    .search-input {
      width: 50%;
      position: relative;
      &:after {
        content: '';
        position: absolute;
        left: -25px;
        right: 0;
        bottom: 8px;
        height: 1px;
        background: rgba(226, 227, 232, 1);
      }
      input {
        outline: none;
        background: transparent;
        border: none;
        outline: medium;
        padding: 0;
        &:focus {
          outline: none;
          background-color: transparent;
        }
      }
    }
    .course-search-btn {
      display: inline-block;
      float: right;
      .el-button.is-round {
        padding: 10px 30px;
        margin-right: 34px;
      }
      .course-search-more {
        font-size: 14px;
        font-weight: 500;
        @include font-color($mainColor);
        cursor: pointer;
        margin-left: 10px;
      }
    }
    &.merge {
      height: 50px;
      line-height: 50px;
    }
    &.separate {
      .course-search-inner {
        padding-top: 10px;
        .search-inner-item {
          .item-label {
            height: 30px;
            line-height: 30px;
            font-size: 14px;
            color: #a6a6a6;
            font-weight: 400;
          }
          .el-input {
            position: relative;
            .el-input__inner {
              border: none;
              padding: 0;
            }
            &:after {
              content: '';
              height: 1px;
              background-color: #e2e3e8;
              position: absolute;
              left: 0;
              right: 0;
              bottom: 0;
            }
          }
        }
      }
      .course-search-btn {
        text-align: center;
        display: block;
        float: none;
        height: 56px;
        line-height: 56px;
      }
    }
  }
  .btn-container {
    display: flex;
    margin-top: 10px;
    .btn-container-title {
      flex: 1;
      height: 46px;
      line-height: 46px;
      font-size: 16px;
      font-weight: bold;
      color: rgba(51, 51, 51, 1);
    }
  }
}
</style>

